/* GUI CONVERTED from rcctdel.p (converter v1.76) Tue Jun 11 06:55:43 2002 */
/* rcctdel.p - Utility to delete/archive unlinked container records           */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.5 $                                                           */
/*                                                                            */
/*  Unlinked Container delete/archive by specifying a range                   */
/*                                                                            */
/* $Revision: 1.5 $       BY:Manish K.        DATE:05/20/02 ECO: *P00C*       */
/*                                                                            */
/*V8:ConvertMode=Report                                                       */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}
{pxmaint.i}

define variable l_site       like abs_shipfrom  label "Site" no-undo.
define variable l_site_to    like abs_shipfrom  label "To"   no-undo.
define variable l_cont       like abs_id        label "Container Number" no-undo.
define variable l_cont_to    like abs_id        label "To" no-undo.
define variable l_cont_type  as character format "x(1)"
                             label "Container Type"
                             initial "S" no-undo.
define variable l_del_sub    like mfc_logical   label "Delete Sub-levels" initial yes no-undo.
define variable rdelete      like mfc_logical   label "Delete" no-undo.
define variable archive      like mfc_logical   label "Archive"  no-undo.
define variable filename     as character       label "Archive File" format "x(12)" no-undo.
define variable c_typelabel  as character format "x(27)" no-undo.

c_typelabel = " S/R/U/" + getTermLabel("BLANK_FOR_ALL",20).


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
l_site      colon 25
   l_site_to   colon 52
   l_cont      colon 25
   l_cont_to   colon 52
   skip(1)
   l_cont_type colon 25
   c_typelabel no-label
   l_del_sub   colon 25
   skip(1)
   rdelete     colon 25
   archive     colon 25
   filename    colon 25
   skip
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/*SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).
view frame a.

global_site = "".

display
   l_site
   l_site_to
   l_cont
   l_cont_to
   l_cont_type
   c_typelabel
   l_del_sub
   rdelete
   archive
   filename
with frame a.

main_blk:
   repeat :
      if l_site_to = hi_char  then l_site_to = "".
      if l_cont_to = hi_char  then l_cont_to = "".

      set
         l_site
         l_site_to
         l_cont
         l_cont_to
         l_cont_type
         l_del_sub
         rdelete
         archive
      with frame a.

      if l_site_to = "" then l_site_to = hi_char.
      if l_cont_to = "" then l_cont_to = hi_char.
      {gprun.i ""gpsirvr.p"" "(l_site, l_site_to, output return_int)" }
      if return_int =  0 then do:
         next-prompt l_site  with frame a.
         undo main_blk, retry main_blk.
      end. /* IF RETURN_INT */

      if l_cont_type <> "S" and
         l_cont_type <> "R" and
         l_cont_type <> "U" and
         l_cont_type <> ""
      then do :
         /* CONTAINER TYPE MUST BE S,R,U or BLANK */
         {pxmsg.i &MSGNUM=1899 &ERRORLEVEL={&APP-ERROR-RESULT}}
         next-prompt l_cont_type with frame a.
         undo main_blk, retry main_blk.
      end. /* IF L_CONT_TYPE */



      /* SET AND DISPLAY ARCHIVE FILE NAME */
      filename =
               if rdelete and archive
               then
                 "cn" + substring(string(year(today),"9999"),3,2)
                      + string(month(today),"99")
                      + string(  day(today),"99")
                      + ".hst"
               else "".
      display filename with frame a.

      /* VALIDATE DELETE FLAG IF ARCHIVING */
      if archive and not rdelete then do:
         /* Cannot archive unless delete is 'yes' */
         {pxmsg.i &MSGNUM=7739 &ERRORLEVEL={&APP-ERROR-RESULT}}
         next-prompt rdelete with frame a.
         undo main_blk, retry main_blk.
      end.  /* IF ARCHIVE */

      /* DISPLAY ARCHIVE MESSAGES */
      else if archive then do:
         /* ARCHIVE FILES SHOULD BE BACKED UP AND DELETED FROM DISK */
         {pxmsg.i &MSGNUM=51 &ERRORLEVEL={&INFORMATION-RESULT}}

         if search(filename) <> ? then do:
            /* <FILENAME> EXISTS, DATA WILL BE APPENDED */
            {pxmsg.i &MSGNUM=52 &ERRORLEVEL={&INFORMATION-RESULT}
                     &MSGARG1=filename}

         end.  /* IF SEARCH */
      end.  /* ELSE IF ARCHIVE */
      /* OUTPUT DESTINATION SELECTION */
      {gpselout.i &printType = "printer" &printWidth = 132
                  &pagedFlag = " "
                  &stream = " "
                  &appendToFile = " "
                  &streamedOutputToTerminal = " "
                  &withBatchOption = "no"
                  &displayStatementType = 1
                  &withCancelMessage = "yes"
                  &pageBottomMargin = 6
                  &withEmail = "yes"
                  &withWinprint = "yes"
                  &defineVariables = "yes"}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.

      {mfphead.i}

      if l_del_sub then do:
         /* DELETE THE ENTIRE CONTAINER STRUCTURE */
         {gprun.i ""rcctdela.p"" "( input l_site,
                                    input l_site_to,
                                    input l_cont,
                                    input l_cont_to,
                                    input l_cont_type,
                                    input rdelete,
                                    input filename)" }
      end. /* IF l_del_sub */
      else  do :
         /* RETAIN THE SUB-LEVELS */
         {gprun.i ""rcctdelb.p"" "( input l_site,
                                    input l_site_to,
                                    input l_cont,
                                    input l_cont_to,
                                    input l_cont_type,
                                    input rdelete,
                                    input filename)" }
      end. /* ELSE DO */


{mfrtrail.i}
end. /* REPEAT : MAIN_BLK */
